function RouterListFormat(data) {
    console.log('77655433')
    let parents = data.filter(p => p.menu_parent_id === 0),
        children = data.filter(c => c.menu_parent_id != 0)
    dataTotree(parents, children)
    //递归函数
    function dataTotree(parents, children) {
        parents.map((p) => {
            children.map((c, index) => {
                if (c.menu_parent_id === p.menu_parent_id) {//如果相同，拷贝children一个新的数组c1
                    let c1 = Object.assign([], children)
                    c1.splice(index, 1)//删除当前元素，获取除当前元素之外的所有子路由元素
                    dataTotree([c], c1);//继续递归
                    if (p.children) {//如果该结点已经存在孩子，则直接加入孩子
                        p.children.push(c)
                    } else {//如果该结点不存在孩子，则让该结点的孩子等于数组c
                        p.children = [c]
                    }
                }
            })
        })
    }
    return parents
}
function add(){
    console.log('2333')
}
//转化为路由表格式
function generateRouter(UserRouter){
    let newRouters = UserRouter.map((r)=>{
        let routes = {
            path:r.menu_url,
            name:r.menu_name,
            component:()=>import(`@/components/${r.menu_component}.vue`)//利用字符串模板拼接
        }
        if(r.children){//如果该结点有孩子，则继续递归
            routes.children = generateRouter(r.children)
        }
        return routes
    })
    return newRouters
}
export default{
    RouterListFormat,
    generateRouter,
    add
}